package com.haoshuang.zhouzhoubang.ui.page.mine.wallet

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.WalletBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class MyWalletViewModel : BaseViewModel() {

    /**
     * 获取钱包主页数据
     */
    val getWalletDetailData = StatefulMutableLiveData<ResponseBean<WalletBean>>()
    fun getWalletDetail() = netRequest {
        start { getWalletDetailData.value = StateData.Loading }
        request { ApiRepo.getWalletDetail()  }
        success { getWalletDetailData.value = StateData.Success(it) }
        error { code, msg ->
            getWalletDetailData.value = StateData.Error(code, msg)
        }
    }

}